package org.wlw.ex;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * catch可以写多个并列多个catch
 * @author konghao
 *
 */
public class TestException03 {
	public static void main(String[] args) {
		try {
			String s = null;
			System.out.println(s.length());
			System.out.println("开始运行");
			int a = divide(12,0);
			System.out.println("-----------------"+a);
		} catch(NullPointerException e) {
			System.out.println(e.getMessage());
		} catch(ArithmeticException e) {
			System.out.println(e.getMessage());
		}
		System.out.println("结束运行");
	}
	
	public static int divide(int a,int b) {
		int n = 0;
		System.out.println("准备开始除法");
		n = a/b;
		System.out.println("除完，准备返回");
		return n;
	}
	
	public static void test() {
		//创建这个类的时候会抛出一个FileNotFoundException。
		//而FileNotFoundException不是RuntimeException。需要程序员手动处理、
		try {
			FileInputStream fis = new FileInputStream("aa");
		} catch(FileNotFoundException e) {
			
		}
	}
}
 